package com.conselheiro.web.beans;

import java.io.Serializable;

import javax.faces.context.FacesContext;

import org.apache.log4j.Logger;

import com.conselheiro.web.facade.Conselheiro;
import com.conselheiro.web.listener.ConselheiroWebStarter;

public abstract class AbstractBean implements Serializable {

	private static final long serialVersionUID = 6450623792771841305L;
	public static final String AUTH_KEY_LOGIN = "USER_LOGIN";

	private static Conselheiro FACADE = (Conselheiro) FacesContext
			.getCurrentInstance().getExternalContext().getApplicationMap()
			.get(ConselheiroWebStarter.FACADE);

	public static Conselheiro getFachada() {
		return FACADE;
	}

	protected String getLogin() {
		return (String) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(AUTH_KEY_LOGIN);
	}

	protected void logarInfo(Logger logger, String info) {
		logger.info(info);
	}

	protected void logarErro(Logger logger, String erro, Exception e) {
		logger.error(erro, e);
	}

}
